package org.easy.sse.dto;

import lombok.Data;

@Data
public class SseFlowDto<T> {

    private String event;
    private String workflow_run_id;
    private String task_id;
    private T data;


    public static <T> SseFlowDto<T> start() {
        SseFlowDto<T> sseFlowDto = new SseFlowDto<>();
        sseFlowDto.setEvent("start");
        return sseFlowDto;
    }


    public static <T> SseFlowDto<T> stop() {
        SseFlowDto<T> sseFlowDto = new SseFlowDto<>();
        sseFlowDto.setEvent("stop");
        return sseFlowDto;
    }

    public static <T> SseFlowDto<T> close() {
        SseFlowDto<T> sseFlowDto = new SseFlowDto<>();
        sseFlowDto.setEvent("close");
        return sseFlowDto;
    }

    public static <T> SseFlowDto<T> failure() {
        SseFlowDto<T> sseFlowDto = new SseFlowDto<>();
        sseFlowDto.setEvent("failure");
        return sseFlowDto;
    }

    public static <T> SseFlowDto<T> failure(SseFlowDto<T> sseFlowDto) {
        sseFlowDto.setEvent("failure");
        return sseFlowDto;
    }

    public static <T> SseFlowDto<T> writing() {
        SseFlowDto<T> sseFlowDto = new SseFlowDto<>();
        sseFlowDto.setEvent("writing");
        return sseFlowDto;
    }

    public static <T> SseFlowDto<T> writingFile(T data) {
        SseFlowDto<T> sseFlowDto = new SseFlowDto<>();
        sseFlowDto.setEvent("writingFile");
        sseFlowDto.setData(data);
        return sseFlowDto;
    }

    public static <T> SseFlowDto<T> writing(T data) {
        SseFlowDto<T> sseFlowDto = new SseFlowDto<>();
        sseFlowDto.setEvent("writing");
        sseFlowDto.setData(data);
        return sseFlowDto;
    }

    public static SseFlowDto init() {
        SseFlowDto sseFlowDto = new SseFlowDto<>();
        sseFlowDto.setEvent("init");
        return sseFlowDto;
    }

    public static <T> SseFlowDto<T> writing(String workflowRunId, String taskId, T data) {
        SseFlowDto<T> sseFlowDto = new SseFlowDto<>();
        sseFlowDto.setEvent("writing");
        sseFlowDto.setData(data);
        sseFlowDto.setWorkflow_run_id(workflowRunId);
        sseFlowDto.setTask_id(taskId);
        return sseFlowDto;
    }


}
